﻿using NeuroCheck.PlugInLib.API;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CLVisionHalconNC620.Dialogs
{
    public partial class RegisterParDialog : Form
    {
        public RegisterParDialog(IEnumerable<string> parStr)
        {
            InitializeComponent();
            foreach (var item in parStr)
            {
                string[] str = item.Split(':');
                dataGridView1.Rows.Add(str);
            }
        }
        public event Action<string> parEvent;
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            ////当前选中行
            //int currentRowIndex = dataGridView1.CurrentCell.RowIndex;
            //int currentColIndex = dataGridView1.CurrentCell.ColumnIndex;
            //if (currentColIndex == 3)
            //{
            //    return;
            //}
            ////该行数据
            //string id = dataGridView1.Rows[currentRowIndex].Cells[0].Value.ToString();
            //string type = dataGridView1.Rows[currentRowIndex].Cells[1].Value.ToString();
            //string category = dataGridView1.Rows[currentRowIndex].Cells[2].Value.ToString();
            //string value = dataGridView1.Rows[currentRowIndex].Cells[3].Value.ToString();
            ////连接字符
            //string connectStr = string.Join(":", new string[] { id, type, category, value });

            //parEvent(connectStr);
            //this.Close();
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
          
            //当前选中行
            int currentRowIndex = dataGridView1.CurrentCell.RowIndex;
            int currentColIndex = dataGridView1.CurrentCell.ColumnIndex;
          
            //该行数据
            string id = dataGridView1.Rows[currentRowIndex].Cells[0].Value.ToString();
            string type = dataGridView1.Rows[currentRowIndex].Cells[1].Value.ToString();
            string category = dataGridView1.Rows[currentRowIndex].Cells[2].Value.ToString();
            string value = dataGridView1.Rows[currentRowIndex].Cells[3].Value.ToString();
            //连接字符
            string connectStr = string.Join(":", new string[] { id, type, category, value });

            parEvent(connectStr);
            this.Close();
        }
    }
}
